package com.feige.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.feige.constant.Constants;
import com.feige.dao.NotifyMsgMapper;
import com.feige.pojo.NotifyMsg;
import com.feige.pojo.vo.NotifyMsgVo;
import com.feige.service.NotifyMsgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 通知消息表 服务实现类
 * </p>
 *
 * @author feige
 * @since 2020-12-26
 */
@Service
public class NotifyMsgServiceImpl extends ServiceImpl<NotifyMsgMapper, NotifyMsg> implements NotifyMsgService {

    @Resource
    private NotifyMsgMapper notifyMsgMapper;

    @Override
    public List<NotifyMsgVo> getNotifyByUserId(int pageNum, String userId) {
        Map<String, Object> map = new HashMap<>(10);
        long pageSize = Constants.PAGE_SIZE * 2;
        map.put("pageNum",(pageNum - 1) * pageSize);
        map.put("pageSize", pageSize);
        map.put("userId",userId);
        return notifyMsgMapper.getNotifyByUserId(map);
    }

    @Override
    public int getNotifyCountByUserId(String userId) {
        return notifyMsgMapper.getNotifyCountByUserId(userId);
    }


}
